package com.itheima.dao;

import com.itheima.domain.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BookDao {


    // 增
    @Insert("insert into tbl_book (id, TYPE, NAME, description) values (null,#{type},#{name},#{description});")
    int save(Book book);

    // 删
    @Delete("delete from tbl_book where id = #{id};")
    int delete(Integer id);

    // 改
    @Update("update tbl_book set TYPE = #{type}, NAME = #{name}, description = #{description} where id = #{id};")
    int update(Book book);

    // 查
    @Select("select * from tbl_book;")
    List<Book> getAll();

    // 查一个
    @Select("select * from tbl_book where id = #{id} ;")
    Book getById(Integer id);












}
